<%@ page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page errorPage="errorPages/error.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>登陆</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="charset" content="UTF-8">


<link href="images/login.css" rel="stylesheet" type="text/css" />
<link href="images/all-purpose.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/jquery.js"></script>
<script type="text/javascript" src="images/jquery.md5.js"></script>
<script type="text/javascript">
$(function() {
	$("#nameError").css("display", "none");
	$("#pwdError").css("display", "none");
	$("#verifyError").css("display", "none");

	// 点击提交按钮时，对密码进行MD5加密
	$("#submit").click(function() {

		if (checkName() & checkPwd() & checkAuthCode()) {
			$("#manPassword").attr("value", $.md5($("#manPassword").val()));
			return true;
		}
		return false;
	});

	// 点击图片更换验证码
	$("#Verify").click(function() {
		$(this).attr("src", "AuthImg?timestamp=" + new Date().getTime());
	});

	var checkName = function() {
		if ($("#manLoginName").val() == "") {
			$("#nameError").css("display", "");
			return false;
		} else {
			$("#nameError").css("display", "none");
			return true;
		}
	};

	var flag = false;
	var checkAuthCode = function() {
		$.ajax({
			type : "post",
			url : "verifyCode",
			data : {
				authCode : $("#authCode").val()
			},
			success : function(data) {
				if (data == "success") {
					$("#verifyError").css("display", "none");
					flag = true;
				} else {
					$("#verifyError").css("display", "");
					flag = false;
				}
			}
		});
		return flag;
	};

	var checkPwd = function() {
		if ($("#manPassword").val() == "") {
			$("#pwdError").css("display", "");
			return false;
		} else {
			$("#pwdError").css("display", "none");
			return true;
		}
	};

});
</script>

</head>

<body>
	<div class="main">
		<h1 style="color:#FFF;">XX图书管理系统</h1>
		<div class="content">
			<span> 用户登录</span>
			<div class="clear"></div>
			<form class="loginbox" action="login" method="post" id="loginbox">

				<table border="0" style="height: 120px">
					<tr>
						<td style="width: 65px;">用户名：</td>
						<td><input name="manager.manLoginName" type="text" value="Guest"
							id="manLoginName" style="width: 165px; height: 24px;" /></td>
						<td><code id="nameError" style="display:none">*</code></td>
					</tr>
					<tr>
						<td style="width: 65px;">密&nbsp;&nbsp;&nbsp;码：</td>
						<td><input name="manager.manPassword" type="password" value="Guest"
							id="manPassword" style="width: 165px; height: 24px;" /></td>
						<td><code id="pwdError" style="display:none">*</code></td>
					</tr>
					<tr>
						<td style="width: 65px; height: 24px;overflow: hidden;">验证码：
						</td>
						<td valign="top"><input type="text" name="authCode"
							id="authCode" class="authCode" /> <img src="AuthImg" id="Verify"
							alt="验证码"></td>
						<td><code id="verifyError" style="display:none">*</code></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input id="submit"
							type="submit" class="loginbt" value="" /> <input id="reset"
							type="reset" class="resetbt" value="" /></td>
						<td></td>
					</tr>
				</table>
			</form>
			<div class="admin">
				<img src="images/admin.png">
			</div>
		</div>
	</div>
	<div align="center" class="#copyright">
		Copyright &copy; 2014-<%=new SimpleDateFormat("yyyy").format(new Date())%>
		by LXG. all rights reserved
	</div>

</body>
</html>
